Repository navigation
fix(openapi): skip wildcard servers and default problem schema to CoreProblemDetails - #15
Merged
Merged
Conversation
In Development, AddCoreOpenApi appends every ASPNETCORE_URLS entry as a "Local" server. Container listen addresses such as http://+:8080 are binding patterns, not URLs a client can call, so they were published in the document. - Skip wildcard hosts (+, *, 0.0.0.0, [::]) when building Local servers. - Document that ProblemResponses.SchemaId defaults to ProblemDetails and must name the error schema in use (for example CoreProblemDetails), otherwise the generated document contains dangling $ref entries.
The default ProblemResponses.SchemaId pointed to a ProblemDetails component that the library does not generate, leaving every problem response with a dangling $ref. CoreProblemDetails is the problem type shipped by this library, so it is now the default, and it is recognized as a problem schema by default as well. Behavior change: consumers that relied on the previous default must set SchemaId = "ProblemDetails" explicitly.
OpenApiRegistrationTests and OpenApiRegistrationCoverageTests both write process-wide environment variables. Running them in parallel made the Development server assertions intermittently fail. Place both classes in the same xUnit collection so they run sequentially.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes two problems that produced an invalid OpenAPI document for consumers of
AddCoreOpenApi.ASPNETCORE_URLSentry was published as a server. Container listen addresses such ashttp://+:8080are binding patterns, not callable URLs. They are now skipped (+,*,0.0.0.0,[::]).ProblemResponses.SchemaIddefaulted toProblemDetails, a component the library never generates. Every problem response referenced it and failed to resolve. The default is nowCoreProblemDetails, the problem type shipped by this library.Behavior change
ProblemResponses.SchemaIdnow defaults toCoreProblemDetails, andProblemSchemaIdsincludes it. Consumers that relied on the previous default must setSchemaId = "ProblemDetails"explicitly. The only known consumer (CoreSystem monorepo sample) is the sole user at the moment, so the impact is limited to it.Test stability
OpenApiRegistrationTestsandOpenApiRegistrationCoverageTestsboth write process-wide environment variables. They now share theProcessEnvironmentxUnit collection, which removes an intermittent failure caused by parallel execution.Verification
dotnet build CoreSystem.OpenApi.slnx -c Release: 0 warnings, 0 errors.dotnet test --solution CoreSystem.OpenApi.slnx -c Release: 168/168 on net8.0, net9.0 and net10.0, repeated five times.